package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchFilterOption;
import com.ruoyi.system.service.IDispatchFilterOptionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 筛选选项Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchFilterOption")
public class DispatchFilterOptionController extends BaseController
{
    @Autowired
    private IDispatchFilterOptionService dispatchFilterOptionService;

    /**
     * 查询筛选选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchFilterOption:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchFilterOption dispatchFilterOption)
    {
        startPage();
        List<DispatchFilterOption> list = dispatchFilterOptionService.selectDispatchFilterOptionList(dispatchFilterOption);
        return getDataTable(list);
    }

    /**
     * 导出筛选选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchFilterOption:export')")
    @Log(title = "筛选选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchFilterOption dispatchFilterOption)
    {
        List<DispatchFilterOption> list = dispatchFilterOptionService.selectDispatchFilterOptionList(dispatchFilterOption);
        ExcelUtil<DispatchFilterOption> util = new ExcelUtil<DispatchFilterOption>(DispatchFilterOption.class);
        util.exportExcel(response, list, "筛选选项数据");
    }

    /**
     * 获取筛选选项详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchFilterOption:query')")
    @GetMapping(value = "/{filterOptionId}")
    public AjaxResult getInfo(@PathVariable("filterOptionId") Long filterOptionId)
    {
        return success(dispatchFilterOptionService.selectDispatchFilterOptionByFilterOptionId(filterOptionId));
    }

    /**
     * 新增筛选选项
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchFilterOption:add')")
    @Log(title = "筛选选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchFilterOption dispatchFilterOption)
    {
        return toAjax(dispatchFilterOptionService.insertDispatchFilterOption(dispatchFilterOption));
    }

    /**
     * 修改筛选选项
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchFilterOption:edit')")
    @Log(title = "筛选选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchFilterOption dispatchFilterOption)
    {
        return toAjax(dispatchFilterOptionService.updateDispatchFilterOption(dispatchFilterOption));
    }

    /**
     * 删除筛选选项
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchFilterOption:remove')")
    @Log(title = "筛选选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{filterOptionIds}")
    public AjaxResult remove(@PathVariable Long[] filterOptionIds)
    {
        return toAjax(dispatchFilterOptionService.deleteDispatchFilterOptionByFilterOptionIds(filterOptionIds));
    }
}
